<template>
    <div class="home">
        <!--上部两个-->
        <Row :gutter="20" type="flex" justify="center" align="middle" class="code-row-bg">
            <Col :xs="24" :sm="9">
                <userInfo :con="dataCon"></userInfo>
            </Col>
            <Col :xs="24" :sm="15">
                <rightData :con="dataCon"></rightData>
            </Col>
        </Row>
        <!--echart图表-->
        <!--<Row :gutter="20" type="flex" justify="center" align="middle" class="code-row-bg">
            <Col :xs="24" :sm="24" :md="12">
                <div class="home-card home-margin-bottom">
                    <echartOne ref="echartTwo" :con="echartTwo" id="echartOne" height="550px" width="100%"></echartOne>
                </div>
            </Col>
            <Col :xs="24" :sm="24" :md="12">
                <div class="home-card home-margin-bottom">
                    <echartTwo ref="echartThreeOne" :con="echartThree" id="echartTwo" height="550px" width="100%"></echartTwo>
                </div>
            </Col>
        </Row>-->
        <!--下部列表-->
        <Row :gutter="20" type="flex" justify="center" align="middle" class="code-row-bg">
            <Col :xs="24" :sm="24" :md="24">
                <listData class="home-margin-bottom" :con="dataCon"></listData>
            </Col>
            <Col>
                <!--<Upload accept="file" type="drag" action="?" :before-upload="getList">-->
                <!--<div class="upImg">-->
                <!--<a><Icon type="ios-cloud-upload" size="52"></Icon></a>-->
                <!--<p>点击或将图片拖拽到这里上传</p>-->

                <!--</div>-->
                <!--点击上传列表-->
                <!--</Upload>-->
                <!--<Upload accept="file" action="">-->
                <!--<Button type="ghost" icon="ios-cloud-upload-outline">点击上传列表</Button>-->
                <!--</Upload>-->
            </Col>
            <Col><input type="file" id="objList"/>
                <Button @click="upLoadNow" style="float: right" type="primary">点击上传表格</Button>
            </Col>
            <!--<Col :xs="24" :sm="24" :md="9"><echartThree ref="echartThree" :con="dataCon" class="home-margin-bottom home-card" id="echartThree" height="450px" width="100%"></echartThree></Col>-->
        </Row>
    </div>
</template>
<script>
    // import Cookies from 'js-cookie';

    import userInfo from "./component/uersInfo.vue"
    import rightData from "./component/rightData.vue"
    import echartOne from "./component/echartOne.vue"
    import echartTwo from "./component/echartTwo.vue"
    import listData from "./component/listData.vue"
    import echartThree from "./component/echartThree.vue"

    export default {
        name: "home",
        components: {userInfo, rightData, echartOne, echartTwo, listData, echartThree},
        data() {
            return {
                dataCon: {},
                echartTwo: {},
                echartThree: {},
                file: {},
            }
        },
        mounted() {
            this.getOneData()
            /*this.getLeftData()
            this.getRightData()*/
        },
        methods: {
            getOneData() {
                this.getJsonData("Index/index", {})
                    .then((res) => {
                        this.dataCon = res
                        console.log(res)
                        // this.$nextTick(()=>{
                        //     this.$refs.echartThree.initChart()
                        // })
                    })
            },
            getLeftData() {
                this.getJsonData("index/getOrderSum", {})
                    .then((res) => {
                        this.echartTwo = res.data
                        this.$nextTick(() => {
                            this.$refs.echartTwo.initChart()
                        })
                    })
            },
            getRightData() {
                this.getJsonData("index/getMemberUp", {})
                    .then((res) => {
                        var arr = [];
                        for (var i = 1; i <= parseInt(res.data.num); i++) {
                            arr.splice(i, 1, i + "日")
                        }
                        this.echartThree = res.data
                        this.echartThree.tian = arr
                        console.log(this.echartThree)
                        this.$nextTick(() => {
                            this.$refs.echartThreeOne.initChart()
                        })
                    })
            },

            upLoadNow() {
                // console.log(file)
                // let reader = new FileReader();
                // let files = new FormData();
                /*console.log(reader)
                reader.onload = () => {
                    this.upNow(reader.result)
                    reader.onload = null;
                };
                // reader.readAsDataURL(file);*/
                // files.append('files',file);
                // this.file = files
                // console.log(this.file)

                let objFile = document.getElementById('objList').files[0]

                let formdata = new FormData()
                formdata.append('files', objFile);
                console.log(objFile)
                this.goUpLoad(formdata)
                // console.log(formdata)
                // this.file = reader

            },
            goUpLoad(files) {
                // const instance=this.$http.create({
                //     withCredentials: true
                // })
                // console.log(this.file)
                // files.append('token',Cookies.get('token'));
                // console.log(files)
                // instance.post(this.ajxaHttpUrl + "Nav/uplExcel",
                //     files
                // )
                //     .then((res) =>{
                //         alert(1)
                //     })
                this.sendFormData("Nav/uplExcel", files)
                    .then((res) => {

                    })
            },
            // upNow(list){
            //     console.log(list)
            // }
        }
    }
</script>
<style lang="less">
    @import "./home";
</style>